package com.service.${packageName};

import static org.junit.Assert.*;

import java.util.HashMap;

import javax.servlet.ServletRequestEvent;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.context.request.RequestContextListener;

import com.common.http.HttpResult;
import com.model.sys.ExceptionLogModel;
import com.model.sys.SysUser;

import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.mock.web.MockServletContext;

import com.model.${packageName}.${table_name}Model;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:config_dev/applicationContext-redis.xml",
		"classpath*:config_dev/springmvc-config.xml", "classpath*:config_dev/spring-mybatis.xml",
		"classpath*:config_dev/activiti.cfg.xml" })
@WebAppConfiguration("src/main/resources")
public class ${table_name}ServiceTest {

	// 声明request变量
	private MockHttpServletRequest request;
	
	@Autowired
	${table_name}Service ${nocapTableName}Service;


	@Before
	public void before() {
		RequestContextListener listener = new RequestContextListener();
		MockServletContext context = new MockServletContext();
		request = new MockHttpServletRequest(context);
		listener.requestInitialized(new ServletRequestEvent(context, request));
		MockHttpSession session = new MockHttpSession();
		session.setAttribute("userType", "1");
		SysUser sysUser=new SysUser();
		sysUser.setUserid("1");
		sysUser.setUsername("2");
		sysUser.setLoginname("3");
		session.setAttribute("sysUser", sysUser);
		request.setSession(session);
	}
	
	@Test
	public void testSelectList() {
		HashMap<String, Object> hashMap = new HashMap<String, Object>();
		HttpResult selectList = ${nocapTableName}Service.selectList(hashMap);
		 
	}

	@Test
	public void testSelectInfor() {
		String idString = "";
		//HttpResult selectList = ${nocapTableName}Service.selectInfor(idString);
		 
	}

	@Test
	public void testSave() {
		${table_name}Model ${nocapTableName}Model = new ${table_name}Model();
		${nocapTableName}Service.save(${nocapTableName}Model);
		 
	}

	@Test
	public void testDelete() {
		 
		String id = "";
		//${nocapTableName}Service.delete(id);
	}

	@Test
	public void testExport() {
		 
	}

}
